package com.sanji.sjmallmodule.account;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.sanji.sjmallapp.BaseActivity;
import com.sanji.sjmallapp.R;
import com.sanji.sjmallutils.Tools;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 修改支付密码
 **/
public class ChangePayPwActivity extends BaseActivity implements View.OnClickListener {

    @BindView(R.id.common_back_img)
    ImageView commonBackImg;
    @BindView(R.id.common_left_tv)
    TextView commonLeftTv;
    @BindView(R.id.store_name_content)
    TextView storeNameContent;
    @BindView(R.id.bing_phone_number)
    TextView bingPhoneNumber;
    @BindView(R.id.before_pass_word)
    EditText beforePassWordEt;
    @BindView(R.id.new_pass_word)
    EditText newPassWordEt;
    @BindView(R.id.repeat_new_pass_word)
    EditText repeatNewPassWordEt;
    @BindView(R.id.change_pw_ok)
    Button changePwOkBtn;
    String beforePassWord;
    String newPassWord;
    String repeatNewPassWord;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_change_pay_pw);
        ButterKnife.bind(this);
        initView();
    }

    public void initView() {
        commonLeftTv.setText(getString(R.string.set_change_pw));
        commonBackImg.setOnClickListener(this);
        changePwOkBtn.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.common_back_img:
                finish();
                break;
            case R.id.change_pw_ok:
                requestData();
                break;
        }
    }

    public void requestData() {
        beforePassWord = beforePassWordEt.getText().toString();
        newPassWord = newPassWordEt.getText().toString();
        repeatNewPassWord = repeatNewPassWordEt.getText().toString();
        if (TextUtils.isEmpty(beforePassWord)) {
            Tools.toastTools(this, getString(R.string.before_pass_word_hint));
            return;
        }
        if (TextUtils.isEmpty(newPassWord)) {
            Tools.toastTools(this, getString(R.string.new_pay_password));
            return;
        }
        if (TextUtils.isEmpty(repeatNewPassWord)) {
            Tools.toastTools(this, getString(R.string.repeat_new_pass_word));
            return;
        }
        if (!(newPassWord.trim().equals(repeatNewPassWord.trim()))) {
            Tools.toastTools(this, getString(R.string.password_no_identical));
            return;
        }
        if (!TextUtils.isEmpty(beforePassWord) && !TextUtils.isEmpty(newPassWord) && !TextUtils.isEmpty(newPassWord) && newPassWord.trim().equals(repeatNewPassWord.trim())) {
            //发送网络请求
        }
    }
}
